package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

type Database struct {
	Alias string `yaml:"alias"`
	Type  string `yaml:"type"`
	DSN   string `yaml:"dsn"`
}

type ServerConfig struct {
	Port int `yaml:"port"`
}

type Config struct {
	Server    ServerConfig `yaml:"server"`
	Databases []Database   `yaml:"databases"`
}

func LoadConfig(path string) (*Config, error) {
	data, err := os.ReadFile(path)
	if err != nil {
		return nil, err
	}

	var cfg Config
	err = yaml.Unmarshal(data, &cfg)
	if err != nil {
		return nil, err
	}

	return &cfg, nil
} 